package com.isoft.airportsystem.service.impl.Flight;

import com.isoft.airportsystem.entity.flight.BoardingGateInfo;
import com.isoft.airportsystem.mapper.Flight.BoardingGateMapper;
import com.isoft.airportsystem.service.flight.BoardingGateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BoardingGateServiceImpl implements BoardingGateService {
    @Autowired
    private BoardingGateMapper boardingGateMapper;

    @Override
    public BoardingGateInfo getByFlightNoAndDate(String flightNumber, String flightDate) {
        return boardingGateMapper.selectByFlightNoAndDate(flightNumber, flightDate);
    }

    @Override
    public BoardingGateInfo getByFlightId(String flightId) {
        List<BoardingGateInfo> list = boardingGateMapper.selectByFlightId(flightId);
        // 返回第一条记录或 null
        return list.isEmpty() ? null : list.get(0);
    }

    @Override
    public List<BoardingGateInfo> findAllBoardingGates() {
        return boardingGateMapper.selectAll();
    }

    @Override
    public boolean addBoardingGate(BoardingGateInfo info) {
        return boardingGateMapper.insertBoardingGate(info) > 0;
    }

    @Override
    public boolean updateBoardingGate(BoardingGateInfo info) {
        return boardingGateMapper.updateBoardingGate(info) > 0;
    }

    @Override
    public boolean deleteBoardingGate(String flightId) {
        return boardingGateMapper.deleteBoardingGate(flightId) > 0;
    }

    @Override
    public List<BoardingGateInfo> getByBoardingGate(String boardingGate) {
        return boardingGateMapper.selectByBoardingGate(boardingGate);
    }

    @Override
    public List<BoardingGateInfo> getByDate(String flightDate) {
        return boardingGateMapper.selectByDate(flightDate);
    }

}
